package chat;

import java.net.*;
import java.io.*;

/**
 * Chat protocol class for ACE4. Contains current state and
 * message (if any).
 * @author derykegan
 *
 */
public class ChatProtocol implements Serializable{
	
	public static final int MESSAGE_FROM_SERVER = 0;	//reading message from server
	public static final int MESSAGE_TO_SERVER = 1;		//writing message to server
	public static final int CLIENT_DISCONNECT = 2;		//client is disconnecting from server
	public static final int SERVER_DISCONNECT = 3;		//server disconnecting or shutting down
	public static final int SERVER_STATUS_MESSAGE = 4;	//client receiving status message from server.
	
	private Message message;
	private int currentState;
	
	/**
	 * Create new chat object
	 * @param state - current state
	 * @param message - message
	 */
	public ChatProtocol(int state, Message message){
		this.currentState = state;
		this.message = message;
	}
	
	/**
	 * returns current state
	 * @return int of current state
	 */
	public int getState(){
		return currentState;
	}
	
	/**
	 * Returns message stored. Note
	 * that it does not check for null
	 * messages!
	 * @return message object
	 */
	public Message getMessage(){
		return message;
	}

}
